package com.grupoconstruobras.sigo.exhumaciones;

import org.dozer.CustomConverter;

public class IdDescripcionConverter implements CustomConverter {

	@Override
	public Object convert(Object destination, Object source,
			Class<?> destClass, Class<?> sourceClass) {
		if (source instanceof Long) {
			return source.toString();
		}
		String duple[] = ((String) source).split("_");
		if (duple != null && duple.length > 0 && !duple[0].equals("")) {
			try {
				return Long.parseLong(duple[0]);
			} catch (Exception e) {
				return 0l;
			}
		}
		return null;
	}

}
